export default class Message {
    static message: Message;

    showAction: Array<messageData> = [];;

    public constructor() {
        Message.message = this;
    }

    public static add(key: string, show: Function, hide: Function) {
        Message.message.showAction.push({
            key: key, showAction: show, hideAction: hide
        });
    }

    public static show(key: string) {
        const showAction = Message.message.showAction;
        showAction.find(u => u.key == key)?.showAction();
    }

    public static hide(key: string) {
        const showAction = Message.message.showAction;
        showAction.find(u => u.key == key)?.hideAction();
    }
}

interface messageData {
    key: string,
    showAction: Function,
    hideAction: Function
}